import { Dispatch } from 'redux'
import { ADD, MINUS } from '@/constants/counter'

export interface CounterAction {
  type: String
}

export const add = (): CounterAction => {
  return {
    type: ADD
  }
}

export const minus = (): CounterAction => {
  return {
    type: MINUS
  }
}

// 异步的action
export const asyncAdd = () => {
  return (dispatch: Dispatch) => {
    setTimeout(() => {
      dispatch(add())
    }, 2000)
  }
}

